package com.xydtech.common.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 全局配置类
 *
 * @author xydtech
 */
@Component
@ConfigurationProperties(prefix = "busiplat")
public class XydtechBusiPlatConfig {
    /** 地区编码 */
    private static String addressCode;
    /** 项目名称 */
    private static String name;
    /** 项目logo */
    private static String logo;
    /** 版本 */
    private static String version;

    /** 版权年份 */
    private static String copyrightYear;

    /** 实例演示开关 */
    private static boolean demoEnabled;

    /** 上传路径 */
    private static String profile;

    /** 获取地址开关 */
    private static boolean addressEnabled;

    /** 保存临时文件路径，使用后删除临时文件 */
    private static String tempFile;


    public static String getAddressCode() {
        return addressCode;
    }

    public static void setAddressCode(String addressCode) {
        XydtechBusiPlatConfig.addressCode = addressCode;
    }

    public static String getName() {
        return name;
    }

    public static String getLogo() {
        return logo;
    }

    public void setLogo(String logo) {
        XydtechBusiPlatConfig.logo = logo;
    }

    public static String getTempFile() {
        return getProfile() + "/templeFile";
    }

    public static void setTempFile(String tempFile) {
        XydtechBusiPlatConfig.tempFile = tempFile;
    }

    public void setName(String name) {
        XydtechBusiPlatConfig.name = name;
    }

    public static String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        XydtechBusiPlatConfig.version = version;
    }

    public static String getCopyrightYear() {
        return copyrightYear;
    }

    public void setCopyrightYear(String copyrightYear) {
        XydtechBusiPlatConfig.copyrightYear = copyrightYear;
    }

    public static boolean isDemoEnabled() {
        return demoEnabled;
    }

    public void setDemoEnabled(boolean demoEnabled) {
        XydtechBusiPlatConfig.demoEnabled = demoEnabled;
    }

    public static String getProfile() {
        return profile;
    }

    public void setProfile(String profile) {
        XydtechBusiPlatConfig.profile = profile;
    }

    public static boolean isAddressEnabled() {
        return addressEnabled;
    }

    public void setAddressEnabled(boolean addressEnabled) {
        XydtechBusiPlatConfig.addressEnabled = addressEnabled;
    }


    /**
     * 获取导入上传路径
     */
    public static String getImportPath() {
        return getProfile() + "/import";
    }

    /**
     * 获取头像上传路径
     */
    public static String getAvatarPath(Long legalPersonOrgId) {
        return getProfile() + "/" + legalPersonOrgId + "/avatar";
    }

    /**
     * 获取产品配置自定义跳转二维码路径
     */
    public static String getPrdDefinedSkipQrcodePath(Long legalPersonOrgId) {
        return getProfile() + "/" + legalPersonOrgId + "/definedSkipQrcode";
    }

    /**
     * 获取下载路径
     */
    public static String getDownloadPath() {
        return getProfile() + "/download/";
    }


    /** 获取客户身份证上传路径 */
    public static String getIdCardPath(Long legalPersonOrgId) {
        return getProfile() + "/" + legalPersonOrgId + "/cust/idcard";
    }

    /** 获取征信报告上传路径 */
    public static String getCreditReportPath() {
        return getProfile() + "/cust/creditreport";
    }

    /**
     *指定子目录通用获取上传路径
     * @Title: getUploadPath
     * @param subFilePath 文件上传子目录（根据业务功能自定义）
     * @return java.lang.String
     * @exception
     * @author JHON
     * @Date 2021/10/20 17:42
     **/
    public static String getUploadPath(String subFilePath) {
        return getProfile() + "/" + subFilePath;
    }

    /**
     *通用获取上传路径
     * @Title: getUploadPath
     * @return java.lang.String
     * @exception
     * @author JHON
     * @Date 2021/10/20 17:42
     **/
    public static String getUploadPath() {
        return getProfile() + "/upload";
    }

    /** 获取电子名片头像上传路径 */
    public static String getEcardFilePath() {
        return getProfile() + "/ecard";
    }
}
